package ltd.newbee.mall.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ltd.newbee.mall.entity.NewBeeMallOrderItem;
import ltd.newbee.mall.entity.Proportion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderItemMapper extends BaseMapper<NewBeeMallOrderItem> {


    @Select("SELECT goods_name,  IFNULL(SUM(selling_price* goods_count),0) as sale  FROM tb_newbee_mall_order_item\n" +
            "GROUP BY goods_id\n" +
            "ORDER BY IFNULL(SUM(selling_price* goods_count),0) desc limit #{rate} ")
    List<Proportion> selectProject(Integer rate);

}
